package org.elkastud;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.elkastud.fasta.FastaSequence;
import org.elkastud.model.MatchResult3;

/**
 * Application state reprezentation
 * @author Mariusz Jasiński
 */
public class Model {
    private SeqCompApp application;
    private List<FastaSequence> sequences;

    private Method method;
    private int smithThreshold;
    private List<MatchResult3> result;

    public Model(SeqCompApp app) {
        this.application = app;
        this.sequences = new ArrayList<FastaSequence>();
    }

    /**
     * Add a sequence to sequences list
     * @param sequence sequence to add
     */
    public void addSequence(FastaSequence sequence) {
        if (!this.sequences.contains(sequence)) {
            this.sequences.add(sequence);
        }
    }

    /**
     * Add a sequences to sequences list
     * @param sequences sequencess to add
     */
    public void addSequence(Collection<FastaSequence> sequences) {
        for (FastaSequence seq : sequences) {
            if (!this.sequences.contains(seq)) {
                this.sequences.add(seq);
            }
        }
    }

    /**
     * @return loaded sequences
     */
    public List<FastaSequence> getSequences() {
        return this.sequences;
    }

    /**
     * remove all sequences
     */
    public void clearSequences() {
        this.sequences.clear();
    }

    /**
     * Set compare alghoritm
     * @param method alghoritm to compare
     */
    public void setMethod(Method method) {
        this.method = method;
    }

    /**
     * @return compare alghoritm
     */
    public Method getMethod() {
        return this.method;
    }

    /**
     * @return the Smitch-Waterman method threshold
     */
    public int getSmitchThreshold() {
        return this.smithThreshold;
    }

    /**
     * Set the Smitch-Waterman method threshold
     * @param threshold
     */
    public void setSmitchThreshold(int threshold) {
        this.smithThreshold = threshold;
    }

    /**
     * Set compare results
     * @param result compare results
     */
    public void setResult(List<MatchResult3> result) {
        this.result = result;
    }

    /**
     * @return compare result
     */
    public List<MatchResult3> getResult() {
        return this.result;
    }
}
